package cn.iocoder.yudao.module.fengdong.smartelderly.controller.app;

import cn.hutool.core.util.ZipUtil;
import cn.iocoder.yudao.module.fengdong.smartelderly.utils.zipUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
 * @author zhangjiasong
 * @description: TODO
 * @date 2024/1/2 16:29
 */
@RestController
@RequestMapping("/zip")
@Log4j2
public class AppZipController {
    @Resource
    zipUtils zipUtils;

    @GetMapping("/downLoad/zip")
    public void download(HttpServletResponse response) throws Exception {
// 指定要下载的文件的URL数组
//        String[] fileUrls = {
//                "https://dummyimage.com/400x400/f279da/79f2e6&text=admin",
//                "https://dummyimage.com/400x400/f279da/79f2e6&text=abd",
//                "https://dummyimage.com/400x400/f279da/79f2e6&text=dwqd"
//        };
        List<String> strings = new ArrayList<>();
        strings.add("https://dummyimage.com/400x400/f279da/79f2e6&text=admin");
        strings.add("https://dummyimage.com/400x400/f279da/79f2e6&text=123213");
        strings.add("https://dummyimage.com/400x400/f279da/79f2e6&text=adm214532in");
        zipUtils.downloadToLocal(strings,response);
    }


}
